﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<GIFT_SHOP_MVC.Models.SanPham>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
   <link href="../../Content/style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
// <![CDATA[

        function submit_btn2_onclick() {
            document.getElementById("Gia").value = "";
            document.getElementById("SL_Ton").value = "";
            document.getElementById("TenSanPham").value = "";
            document.getElementById("Hinh").value = "";
            document.getElementById("MoTa").value = "";
        }

// ]]>
    </script>
    <style type="text/css">
        .style1
        {
            width: 100%;
            
        }
        .style2
        {
            width: 100%;
            background-color:White;         
        }
    </style>
</head>
<body style="background:#e1d1d6;">

<%
    GIFT_SHOP_MVC.Models.GiftShop_LinQDataContext data = new GIFT_SHOP_MVC.Models.GiftShop_LinQDataContext();
    var lstcate = data.GetCategories();
    SelectList listcate = new SelectList(lstcate,"MaTheLoai","TenTheLoai");
    var lstsup = data.GetSuppliers();
    SelectList listsup = new SelectList(lstsup,"MaNhaCungCap","TenNhaCungCap");
    var lstpro = data.GetProduct();
    SelectList listpro = new SelectList(lstpro, "MaSanPham", "TenSanPham");
     %>
    <a href="../../Admin/FormProduct/1" target="main_frame">Create A New Product</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../Admin/FormProduct/2" target="main_frame">Product Available</a>
    
    <% if ((int)Session["type"] == 1)
       { %>

    <form id="form_pro" action="../../Admin/AddTable" target="main_frame" method="post" enctype="multipart/form-data">
        <fieldset>
            <legend>Product Information</legend>
            <table class="style1" cellspacing="15">
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.TenSanPham) %>
                    </td>
                    <td>
                    <%: Html.TextBoxFor(m => m.TenSanPham)%>
                    <b style="color:Red;"><%: Html.ValidationMessageFor(m => m.TenSanPham)%></b>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.MaTheLoai) %></td>
                    <td>
                    <%: Html.DropDownListFor(m => m.MaTheLoai, listcate)%>
                    <%: Html.ValidationMessageFor(m => m.MaTheLoai)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.MaNhaCungCap) %></td>
                    <td>
                        <%: Html.DropDownListFor(m => m.MaNhaCungCap, listsup)%>
                        <%: Html.ValidationMessageFor(m => m.MaNhaCungCap)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.Hinh) %></td>
                    <td>
                        <input type="file" id="Hinh" name="Hinh" />
                        <b style="color:Red;"><%: Html.ValidationMessageFor(m => m.Hinh)%>
                    </td >
                </tr>
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.MoTa) %></td>
                    <td>
                        <%: Html.TextAreaFor(m => m.MoTa)%>
                        <b style="color:Red;"><%: Html.ValidationMessageFor(m => m.MoTa)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.Gia) %></td>
                    <td>
                        <%: Html.TextBoxFor(m => m.Gia)%>
                        <b style="color:Red;"><%: Html.ValidationMessageFor(m => m.Gia)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.SL_Ton) %></td>
                    <td>
                        <%: Html.TextBoxFor(m => m.SL_Ton)%>
                        <b style="color:Red;"><%: Html.ValidationMessageFor(m => m.SL_Ton)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" id="submit_btn2" value="Clear" onclick="return submit_btn2_onclick()" /></td>
                    <td>
                        <input type="submit" id="submit_btn" value="Add Product" /></td>
                </tr>
            </table>
        </fieldset>
    </form>
    <%}
       else
       {%>
       <form id="form_pro" action="../../Admin/AddTable" target="main_frame" method="post">
        <fieldset>
            <legend>Product Information</legend>
            <table class="style1" cellspacing="20">
                <tr>
                    <td>
                        <%: Html.LabelFor(model => model.TenSanPham) %>
                    </td>
                    <td>
                    <%: Html.DropDownListFor(m => m.MaSanPham,listpro)%>
                    <input type="hidden" name="TenSanPham" value="aaa" />
                    <%: Html.ValidationMessageFor(m => m.TenSanPham) %>
                    <input type="hidden" name="Hinh" value="aaa" />
                    <%: Html.ValidationMessageFor(m => m.Hinh)%>
                    <input type="hidden" name="MoTa" value="aaa" />
                    <%: Html.ValidationMessageFor(m => m.MoTa)%>
                </tr>
                <%--<tr>
                    <td>
                        Category</td>
                    <td>
                    <%: Html.DropDownListFor(m => m.MaTheLoai, listcate)%>
                    <%: Html.ValidationMessageFor(m => m.MaTheLoai)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        Supplier</td>
                    <td>
                        <%: Html.DropDownListFor(m => m.MaNhaCungCap, listsup)%>
                        <%: Html.ValidationMessageFor(m => m.MaNhaCungCap)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        Image</td>
                    <td>
                        <input type="file" id="File1" name="Hinh" />
                        <%: Html.ValidationMessageFor(m => m.Hinh)%>
                    </td >
                </tr>
                <tr>
                    <td>
                        Description</td>
                    <td>
                        <%: Html.TextAreaFor(m => m.MoTa)%>
                        <%: Html.ValidationMessageFor(m => m.MoTa)%>
                    </td>
                </tr>--%>
                <tr>
                    <td>
                        Price</td>
                    <td>
                        <%: Html.TextBoxFor(m => m.Gia)%>
                        <%: Html.ValidationMessageFor(m => m.Gia)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        Number</td>
                    <td>
                        <%: Html.TextBoxFor(m => m.SL_Ton)%>
                        <%: Html.ValidationMessageFor(m => m.SL_Ton)%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" id="submit_btn2" value="Clear" onclick="return submit_btn2_onclick()" /></td>
                    <td>
                        <input type="submit" id="submit_btn" value="Add Product" /></td>
                </tr>
            </table>
        </fieldset>
    </form>

      <%} %>

    <br />

    <iframe name="table" src="../../Admin/ShowTable" frameborder="0" scrolling="auto" width="650" height="400"></iframe>
    
    <br />
    <br />
    <% if (Session["table"] != null)
       {%>
       <tr style="background-color:#D1DDF1; font-weight:bold; Color:#333333; text-align:center;">
                    <td colspan="2">
                        &nbsp;</td>
                    <td colspan="2">
                        <a href="../../Admin/AddProduct" target="main_frame" ><input type="button" id="submit_btn" value="Submit" /></a>
                        </td>
                    <td colspan="2">
                        &nbsp;</td>
                    <td colspan="2">
                        <a href="../../Admin/DeleteTable/-1" target="main_frame" ><input type="button" id="submit_btn" value="Clear" /></a>
                        </td>
        </tr>
        
        <%} %> 
</body>
</html>

